<template>
  <div class="article" v-if="article">
    <!-- 顶部导航开始 -->
    <!-- <router-link slot="left" to="/home"> -->
    <van-nav-bar
      title="文章详情"
      left-arrow
      @click-left="onClickLeft"
      style="background-color: #1074ff"
    />
    <!-- </router-link> -->
    <!-- 导航导航结束 -->
    <!-- 正文区域开始 -->
    <div class="question" v-for="(item, i) in article.data" :key="i">
      <!-- 标题开始 -->
      <div class="question-header">
        <div class="question-header-title">
          {{ item.title }}
        </div>
        <div class="question-header-datetime">
          {{ moment.unix(item.created_date).format("YYYY年MM月DD日 HH:mm") }}
        </div>
      </div>
      <!-- 标题结束 -->

      <!-- 内容开始 -->
      <div class="question-content">
        <div class="rich-content" v-html="item.content"></div>
      </div>
      <!-- 内容结束 -->
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      article: {},
    };
  },
  mounted() {
    let id = this.$route.query.id;
    this.axios
      .get(`${this.$base}article/detail?id=${id}`)
      .then((res) => {
        // console.log(res.data.data);
        this.article = res.data;
      });
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped>
.van-nav-bar {
  background-color: #1074ff !important;
  /deep/ .van-nav-bar__title {
    color: #fff !important;
  }
  /deep/ .van-icon-arrow-left {
    color: #fff !important;
  }
}
.article {
  background: #f6f6f6;
  height: 100vh;
}

// .question {
//   width: 95%;
//   margin: 0 auto;
//   .rich-content {
    
//   }
// }
.question-header {
  margin-bottom: 5px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.1);
}
.question-header-title {
  font-weight: 700;
  font-size: 16px;
  color: #1a1a1a;
  line-height: 1.5;
}
.question-header-datetime {
  margin-top: 5px;
  font-size: 14px;
  color: #646464;
}
.author-info {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  padding: 8px 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.1);
}
.author-info-avatar {
  width: 40px;
  height: 40px;
  border-radius: 100%;
}
.author-info-detail {
  margin-left: 15px;
}
.author-info-nickname {
  font-size: 15px;
  margin-bottom: 6px;
}
.author-info-badge {
  font-size: 14px;
}
.question-content {
  padding: 10px;
  background-color: #fff;
}

/deep/ .rich-content p {
  img {
    width: 100%;
  }
}
</style>


